/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.soa.util.rsgl;

import com.lianzt.commondata.AbstractCommonData;
import com.soa.service.BaseService;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 * P90003
 *定时检查警衔更新
 * @author Administrator
 */
@Service
public class DsjcJxgx extends BaseService{

    @Override
    public String[] keys() {
        return null;
    }

    @Override
    public void execute(AbstractCommonData in, AbstractCommonData inhead, AbstractCommonData out, AbstractCommonData outhead) {
        List<AbstractCommonData> list = new ArrayList<AbstractCommonData>();
        String now_date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        list = queryList("ds_search_jx", new Object[]{});
        if(list.size()>0){
            for (AbstractCommonData abs : list) {
                String sxsj = abs.getStringValue("sxsj");
                if(now_date.equals(sxsj)){
                    AbstractCommonData gr = queryData("ds_search_gr", new Object[]{abs.getStringValue("ssgrbh")});
                    if(gr!=null){
                        String xjx = gr.getStringValue("xjx");
                        int jx = Integer.parseInt(xjx);
                        if(jx<6){
                            jx=jx+1;
                        }
                        update("ds_update_gr_xjx",new Object[]{jx,gr.getStringValue("id")});
                    }
                }
            }
        }
    }
    
}
